package cn.aloxc.tianya.reader;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemSelectedListener;
import cn.aloxc.custom.ImageAdapter;

public class Activity_test_list_gridview extends Activity
	implements OnItemClickListener,OnItemSelectedListener
{
	private GridView gridView = null;
	private ImageView image = null;
	private ImageAdapter adapter = null;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		gridView = (GridView)this.findViewById(R.id.test_gridview_gridview);
		image = (ImageView)this.findViewById(R.id.test_gridview_ImageView01);
		adapter = new ImageAdapter(this);
		gridView.setAdapter(adapter);
		gridView.setOnItemClickListener(this);
		gridView.setOnItemSelectedListener(this);
	}

	@Override
	public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
		new AlertDialog.Builder(this)
			.setTitle("图片浏览")
			.setIcon(adapter.getcheckedImageIdPosition(arg2))
			.setPositiveButton("返回",new OnClickListener(){
				@Override
				public void onClick(DialogInterface arg0, int arg1) {
				}}
			).show();
		
		
	}
	@Override
	public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2,
			long arg3) {
		image.setImageResource(adapter.getcheckedImageIdPosition(arg2
				));
	}
	@Override
	public void onNothingSelected(AdapterView<?> arg0) {
		
	}
}
